| Conditions | 3 |
| Total Lines | 30 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | // jshint esversion: 8 |
||
| 11 | function resetUiCounters(event) { |
||
| 12 | var { |
||
| 13 | sender |
||
| 14 | } = event; |
||
| 15 | |||
| 16 | debug("Resetting bulk whois UI counters"); |
||
| 17 | |||
| 18 | var baseValues = { |
||
| 19 | integer: 0, |
||
| 20 | string: '-' |
||
| 21 | }, |
||
| 22 | events = { |
||
| 23 | integer: [ |
||
| 24 | 'time.current', 'time.remaining', // Timers |
||
| 25 | 'laststatus.available', 'laststatus.unavailable', 'laststatus.error' // Last domain status |
||
| 26 | ], |
||
| 27 | string: [ |
||
| 28 | 'domains.total', 'domains.waiting', 'domains.sent', 'domains.processed', // Domains |
||
| 29 | 'reqtimes.maximum', 'reqtimes.minimum', 'reqtimes.last', 'reqtimes.average', // Request times |
||
| 30 | 'status.available', 'status.unavailable', 'status.error' // Number stats |
||
| 31 | ] |
||
| 32 | }, |
||
| 33 | channel = 'bw:status.update'; |
||
| 34 | |||
| 35 | // Loop through events and send default values |
||
| 36 | for (var eventType in events) |
||
|
|
|||
| 37 | for (var listedEvent in events[eventType]) |
||
| 38 | sender.send(channel, events[eventType][listedEvent], baseValues[eventType]); |
||
| 39 | |||
| 40 | } |
||
| 41 | |||
| 46 |
When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically: